<?php
class MidAutumnVo extends SzAbstractMySqlVo
{

    private $userId;
    private $session;
    private $point;
    private $reward;
    private $freeAdmissionTime;
    private $finalStatus;
    private $hasPos;
    private $createTime;
    private $updateTime;
    private $endTime;

    /**
     * Initialize MidAutumnVo.
     *
     * @param $userId
     * @param $session
     * @param $point
     * @param $reward
     * @param $freeAdmissionTime
     * @param $finalStatus
     * @param $hasPos
     * @param $createTime
     * @param $updateTime
     * @param $endTime
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return MidAutumnVo
     */
    public function __construct($userId, $session, $point, $reward, $freeAdmissionTime, $finalStatus, $hasPos, $createTime, $updateTime, $endTime, $isInsert = false) {
        $this->userId = $userId;
        $this->session = $session;
        $this->point = $point;
        $this->reward = json_decode($reward, true);
        $this->freeAdmissionTime = $freeAdmissionTime;
        $this->finalStatus = $finalStatus;
        $this->hasPos = $hasPos;
        $this->createTime = $createTime;
        $this->updateTime = $updateTime;
        $this->endTime = $endTime;

        $this->isInsert = $isInsert;
        $this->voClassName = 'MidAutumnVo';
        $this->ormName = 'MidAutumn';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'session' => $this->getSession(),
            'point' => $this->getPoint(),
            'reward' => ($needEncode) ? $this->getReward() : $this->getRawReward(),
            'freeAdmissionTime' => $this->getFreeAdmissionTime(),
            'finalStatus' => $this->getFinalStatus(),
            'hasPos' => $this->getHasPos(),
            'createTime' => $this->getCreateTime(),
            'updateTime' => $this->getUpdateTime(),
            'endTime' => $this->getEndTime(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'session' => $this->getSession(),
            'point' => $this->getPoint(),
            'reward' => ($needEncode) ? $this->getReward() : $this->getRawReward(),
            'freeAdmissionTime' => $this->getFreeAdmissionTime(),
            'finalStatus' => $this->getFinalStatus(),
            'hasPos' => $this->getHasPos(),
            'createTime' => $this->getCreateTime(),
            'updateTime' => $this->getUpdateTime(),
            'endTime' => $this->getEndTime(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getSession(),
            $this->getPoint(),
            $this->getReward(),
            $this->getFreeAdmissionTime(),
            $this->getFinalStatus(),
            $this->getHasPos(),
            $this->getCreateTime(),
            $this->getUpdateTime(),
            $this->getEndTime(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getSession()
    {
        return $this->session;
    }

    public function setSession($val)
    {
        $this->saveColumnStatus(1, $this->session);
        $this->session = $val;
    }

    public function getPoint()
    {
        return $this->point;
    }

    public function setPoint($val)
    {
        $this->saveColumnStatus(2, $this->point);
        $this->point = $val;
    }

    public function getReward()
    {
        return json_encode($this->reward);
    }

    public function getRawReward()
    {
        return $this->reward;
    }

    public function setReward($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[MidAutumnVo] The length of column reward exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('MidAutumnVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[MidAutumnVo] The length of column reward exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(3, $this->reward);
        $this->reward = $val;
    }

    public function getFreeAdmissionTime()
    {
        return $this->freeAdmissionTime;
    }

    public function setFreeAdmissionTime($val)
    {
        $this->saveColumnStatus(4, $this->freeAdmissionTime);
        $this->freeAdmissionTime = $val;
    }

    public function getFinalStatus()
    {
        return $this->finalStatus;
    }

    public function setFinalStatus($val)
    {
        $this->saveColumnStatus(5, $this->finalStatus);
        $this->finalStatus = $val;
    }

    public function getHasPos()
    {
        return $this->hasPos;
    }

    public function setHasPos($val)
    {
        $this->saveColumnStatus(6, $this->hasPos);
        $this->hasPos = $val;
    }

    public function getCreateTime()
    {
        return $this->createTime;
    }

    public function setCreateTime($val)
    {
        $this->saveColumnStatus(7, $this->createTime);
        $this->createTime = $val;
    }

    public function getUpdateTime()
    {
        return $this->updateTime;
    }

    public function setUpdateTime($val)
    {
        $this->saveColumnStatus(8, $this->updateTime);
        $this->updateTime = $val;
    }

    public function getEndTime()
    {
        return $this->endTime;
    }

    public function setEndTime($val)
    {
        $this->saveColumnStatus(9, $this->endTime);
        $this->endTime = $val;
    }

}